package com.utils.base;

import android.content.Context;
import android.os.Looper;
import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;

/**
 * Created by Android Studio.
 * User: tanyan
 * Date: 2020-03-18
 * Time: 13:24
 */
public class ToastUtils {
    private static Toast toast = null;

    public static void showToast(Context context, String text) {
        try {
            Toast.makeText(context, text, Toast.LENGTH_LONG).show();
        } catch (Exception e) {
            Log.e("TOAST","弹窗错误");
        }
//        Looper myLooper = Looper.myLooper();
//        if (myLooper == null) {
//            Looper.prepare();
//            myLooper = Looper.myLooper();
//        }
//
//        if (toast == null) {
//            toast = Toast.makeText(context, text, Toast.LENGTH_LONG);
//            toast.setGravity(Gravity.CENTER, 0, 0);
//        }
//        toast.show();
//        if ( myLooper != null) {
//            Looper.loop();
//            myLooper.quit();
//        }
    }
}
